home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jaz_clib.arc / DOSWRITS.ASM < prev    next >
Assembly Source File  |  1989-04-09  |  2KB  |  45 lines

  1. Comment *
  2. ┌────────────────────────────────────────────────────────────────────────────┐
  3. │doswrits.asm                                                                │
  4. │Allows direct sector access from 'C' which is not possible using int86      │
  5. │because this int leaves a word on the stack which would cause int86 to      │
  6. │return to some unknown place.                                               │
  7. │usage:                                                                      │
  8. │char wbuf[512];          at lease 512 bytes for sector buffer               │
  9. │int werror;                                                                 │
  10. │                                                                            │
  11. │werror = doswrits(0,0,1,wbuf);    writes to drive 'A',sector 0, 1 sector,   │
  12. │                                  from wbuf                                 │
  13. │                                                                            │
  14. │                                                                            │
  15. │ (C) JazSoft Software by Jack A. Zucker (301) 794-5950                      │
  16. └────────────────────────────────────────────────────────────────────────────┘
  17. *
  18.         assume cs:_text
  19. _text   segment public byte 'code'
  20.         public _doswrits
  21.  
  22. _doswrits   proc near
  23.  
  24.         push bp
  25.         mov bp,sp
  26.         push si                 ; save user's "C" register variables
  27.         push di
  28.  
  29.         mov al,[bp+4]           ; drive number
  30.         mov dx,[bp+6]           ; which sector to write
  31.         mov cx,[bp+8]           ; amount of sectors
  32.         mov bx,[bp+0Ah]         ; offset of buffer
  33.         int 26h
  34.         jc _doswritserror       ; if carry then error occurred
  35.         mov ax,0                ; else return a zero
  36. _doswritserror:
  37.         popf                    ; int 25h pushes flags
  38.         pop di                  ; restore user's "C" register variables
  39.         pop si
  40.         pop bp                  ; restore base pointer
  41.         ret
  42. _doswrits   endp
  43. _text   ends
  44. end
  45.